/**
 * BaseServlet.java
 * 
 * Copyright(C)2010 FOUNDER CORPORATION
 * 
 */

package org.iori.luodan.base;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.iori.common.log.FounderLog;
import com.iori.common.log.LogFactory;

/**
 * [クラス名]<br>
 * BaseServlet.java<br>
 * [機能概要]<br>
 * <br>
 * <br>
 * [変更履歴]<br>
 * 2012/11/12 ver1.00 新規作成<br>
 * 
 * @author lun_xing
 * @version 1.00
 */
public abstract class BaseStatListener extends TimerTask implements ServletContextListener {
	//Log出力クラスを定義
	private static FounderLog logger = LogFactory
			.getFounderLog(BaseStatListener.class);
	
	private Timer timer = new Timer();
	
	protected Date startDate = new Date();
	
	protected long period = 5 * 60 * 1000;
	
	public void contextInitialized(ServletContextEvent sce) {
		timer.schedule(this, startDate, period);
	}
	
	public void contextDestroyed(ServletContextEvent sce) {
		timer.cancel();
	}
	
	public void run() {
		logger.debug("TimerTask run start：");
		this.doExcute();
		logger.debug("TimerTask run end：");
	}
	
	protected abstract void doExcute();
	
}